import { PureComponent } from 'react';
import moment from 'moment';
import {
    Row,
    Col,
    Form,
    Input,
    Select,
    Modal,
    Cascader,
    DatePicker
} from 'antd';
const FormItem = Form.Item;
const { Option } = Select;
import { dicTextByCodePcode,dicListByPcode } from '@/utils/dictionary'


@Form.create()
class CreateForm extends PureComponent {

	constructor(props) {
	    super(props);
	    this.state = {

	    }
	}


	okHandle = () => {
		const { form,handleAdd } = this.props;

	    form.validateFields((err, fieldsValue) => {
		        if (err) return;
		        form.resetFields();
			   if(fieldsValue.a5007) {
			   			fieldsValue.a5007 = moment(fieldsValue.a5007._d).format("YYYY-MM-DD");
			   		}
			   if(fieldsValue.a5023) {
			   			fieldsValue.a5023 = moment(fieldsValue.a5023._d).format("YYYY-MM-DD");
			   		}
			    handleAdd(fieldsValue,'DisciplineInfo');
		});
	};


	resetButton = () => {

	};

  render() {
    const {form: {getFieldDecorator}, modalVisibleByDisciplineInfo,handleModalVisible} = this.props;

return (
    <Modal
width={800}
destroyOnClose
title="添加惩戒信息"
visible={modalVisibleByDisciplineInfo}
onOk={this.okHandle}
onCancel={() => handleModalVisible(false,"DisciplineInfo")}
afterClose={() => this.resetButton()}
>
<Form  layout="vertical">
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>

		    <Col md={12} sm={24}>
		      <FormItem  label="惩戒名称">
		          {getFieldDecorator('a5004_1', {
		          rules: [{ required: false, message: '请输入1-10个字符',max: 10}],
		          })(<Input placeholder="1-10个字符"/>)}
		      </FormItem>
		    </Col>

		    <Col md={12} sm={24}>
		      <FormItem  label="惩戒类别">
		          {getFieldDecorator('a5001', {
		            rules: [{ required: false, message: '请选择'}],
		          })(
		            <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		            	{dicListByPcode('AE') != undefined?dicListByPcode('AE').map((item,index) => {
		            		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		            	}):null}
		            </Select>
		          )}
		      </FormItem>
		    </Col>

		</Row>
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>

		    <Col md={12} sm={24}>
		      <FormItem  label="惩戒代码">
		          {getFieldDecorator('a5004_2',{
		          })(
		          	<Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		          		{dicListByPcode('AE') != undefined?dicListByPcode('AE').map((item,index) => {
		          			return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		          		}):null}
		          	</Select>
		          )}
		      </FormItem>
		    </Col>
		    <Col md={12} sm={24}>
		      <FormItem  label="受惩戒时职务及职级">
		          {getFieldDecorator('a5015', {
		          rules: [{ required: false, message: '1-10个字符'}],
		          })(
		           <Input placeholder="1-10个字符" />
		          )}
		      </FormItem>
		    </Col>

		</Row>

		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>

		<Col md={12} sm={24}>
		      <FormItem  label="惩戒事件序号">
		          {getFieldDecorator('a5025', {
		          rules: [{ required: false, message: '1-10个字符'}],
		          })(
		          	<Input placeholder="1-10个字符" />
		          )}
		      </FormItem>
		    </Col>

		    <Col md={12} sm={24}>
		      <FormItem  label="惩戒原因">
		          {getFieldDecorator('a5017',{
		            rules: [{ required: false, message: '请选择！'}],
		          })(
		          	<Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		              {dicListByPcode('R1') != undefined?dicListByPcode('R1').map((item,index) => {
		                return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		              }):null}
		            </Select>
		          )}
		      </FormItem>
		    </Col>

		</Row>

		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>


		    <Col md={12} sm={24}>
		      <FormItem  label="惩戒事由">
		          {getFieldDecorator('a5021', {
		          rules: [{ required: false, message: '1-10个字符'}],
		          })(
		            <Input placeholder="1-10个字符" />
		          )}
		      </FormItem>
		    </Col>
		    <Col md={12} sm={24}>
		      <FormItem  label="批准日期">
		          {getFieldDecorator('a5007', {
		          rules: [{ required: false, message: '请选择'}],
		          	  })(
		          		<DatePicker  format="YYYY-MM-DD" style={{ width: '100%' }} placeholder="请选择"/>
		          		)}
		            </FormItem>
		    </Col>

		</Row>

		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>


		    <Col md={12} sm={24}>
		      <FormItem  label="批准机关名称">
		          {getFieldDecorator('a5011_1', {
		          rules: [{ required: false, message: '1-10个字符' }],
		          })(<Input placeholder="1-10个字符" />)}
		      </FormItem>
		    </Col>

		   	<Col md={12} sm={24}>
		   	  <FormItem  label="批准机关代码">
		   	      {getFieldDecorator('a5011_2', {
		   	      rules: [{ required: false, message: '1-10个字符' }],
		   	      })(<Input placeholder="1-10个字符" />)}
		   	  </FormItem>
		   	</Col>

		</Row>
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>


		    <Col md={12} sm={24}>
		   	  <FormItem  label="批准文件名称及文号">
		   	      {getFieldDecorator('a5026', {
		   	      rules: [{ required: false, message: '1-10个字符' }],
		   	      })(<Input placeholder="1-10个字符" />)}
		   	  </FormItem>
		   	</Col>
			<Col md={12} sm={24}>
			  <FormItem  label="批准机关类别">
			      {getFieldDecorator('a5012', {
			        rules: [{ required: false, message: '请选择'}],
			        })(
			        <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
			        	{dicListByPcode('BG') != undefined?dicListByPcode('BG').map((item,index) => {
			        		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
			        	}):null}
			        </Select>
			      )}
			  </FormItem>
			</Col>

		</Row>

		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>

		<Col md={12} sm={24}>
		  <FormItem  label="是否解除变更">
		      {getFieldDecorator('a5022', {
		        rules: [{ required: false, message: '请选择'}],
		        })(
		        <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		        	{dicListByPcode('BG') != undefined?dicListByPcode('BG').map((item,index) => {
		        		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		        	}):null}
		        </Select>
		      )}
		  </FormItem>
		</Col>

			<Col md={12} sm={24}>
			  <FormItem  label="解除变更惩戒日期">
			      {getFieldDecorator('a5023', {
			        rules: [{ required: false, message: '请选择'}],
		          	  })(
		          		<DatePicker  format="YYYY-MM-DD" style={{ width: '100%' }} placeholder="请选择"/>
		          		)}
		            </FormItem>
			</Col>

		</Row>

		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>


		    <Col md={12} sm={24}>
		   	  <FormItem  label="解除变更惩戒原因">
		   	      {getFieldDecorator('a5024', {
		   	      rules: [{ required: false, message: '1-10个字符' }],
		   	      })(<Input placeholder="1-10个字符" />)}
		   	  </FormItem>
		   	</Col>


		</Row>

</Form>
</Modal>
);
  }

}

export default CreateForm;
